package cn.yuxiaoyuan.Interface;

import cn.dev33.satoken.stp.StpInterface;
import cn.yuxiaoyuan.constants.RedisCacheConstants;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @author solargen
 * @version 1.0
 * @date 2025/6/18 14:32
 */
@Component
public class StpInterfaceImpl implements StpInterface {
    @Autowired
    private RedisTemplate<String,Object> redisTemplate;
    @Override
    public List<String> getPermissionList(Object id, String s) {
        List<String> userPermission = (List<String>)redisTemplate.opsForValue()
                .get(RedisCacheConstants.USER_PERMISSION_KEY + Long.valueOf(id.toString()));
        return userPermission;


    }

    @Override
    public List<String> getRoleList(Object id, String s) {
        List<String> userRole = (List<String>)redisTemplate.opsForValue()
                .get(RedisCacheConstants.USER_ROLE_KEY + Long.valueOf(id.toString()));
        return userRole;
    }
}
